import React, { Component } from 'react'
import { Row, Col} from 'antd'
import './home.less'
import { withRouter } from 'react-router-dom'
import Header from '../../components/Header/header'
import Footer from '../../components/Footer/footer'

class HomeView extends Component {

  componentWillMount() {
    const userInfo = window.localStorage.getItem('userName');
    // const remember = window.localStorage.getItem('remember');
    const userName = userInfo ? JSON.parse(userInfo).userName : '';
    if (!userName) {
      this.props.history.push('login');
    }
    this.props.commitUserInfo({userName});
  }

  render() {
    return (
      <Row className="home">
        <Col span={24} className="home-body">
          <Header></Header>
          <section className="home-content">
            {this.props.children}
          </section>
          <Footer></Footer>
        </Col>
      </Row>
    )
  }
}

export default withRouter(HomeView);
